extends ../../layout

block css
    link(rel="stylesheet", href="/css/addon/sticky.almost-flat.min.css")
    link(rel="stylesheet", href="/css/dashboard/overlayer.css")
    link(rel="stylesheet", href="/css/dashboard/navbar.css")
    link(rel="stylesheet", href="/css/dashboard/analytics.css")
block js
    script(data-main="/js/entry/analytics/chaincode" src="/js/lib/require.js")
block content
    include ../includes/navbar.pug
    +active("analytics")
    section.ds-analytics.uk-container.uk-container-center.uk-padding-remove
        .uk-grid
            .uk-width-1-5
                include includes/catalog.pug
                +active("chaincode")
            .uk-width-4-5
                include includes/chainSelector.pug
                #analyticsPanel.uk-margin-top
                    if chaincodes.length
                        .uk-grid.uk-margin-large-top
                            .uk-text-center
                                .uk-text-truncate.uk-margin-bottom.perfect-health-square
                                    label.font-size-15 Chaincode
                                    .uk-vertical-align.health-label-box
                                        label.uk-vertical-align-middle.perfect-label Perfect
                                label.font-size-20 Health
                            .uk-vertical-align
                                .uk-vertical-align-middle.vertical-line(style="margin-bottom:37px;")
                            .uk-text-center
                                .uk-vertical-align.uk-margin-bottom(style="height:156px;")
                                    label.uk-vertical-align-middle.font-size-50= chaincodes.length
                                label.font-size-20 Chaincodes
                            .uk-vertical-align
                                .uk-vertical-align-middle.vertical-line(style="margin-bottom:37px;")
                            .uk-text-center
                                .uk-vertical-align.uk-margin-bottom(style="height:156px;")
                                    label.uk-vertical-align-middle.uk-margin-small-right.font-size-50= invokeTimes
                                    label.uk-vertical-align-middle.font-size-20(style="margin-top:20px;")
                                        = invokeTimes <= 1 ? "time" : "times"
                                label.font-size-20 Invoke
                            .uk-vertical-align
                                .uk-vertical-align-middle.vertical-line(style="margin-bottom:37px;")
                            .uk-text-center
                                .uk-vertical-align.uk-margin-bottom(style="height:156px;")
                                    label.uk-vertical-align-middle.uk-margin-small-right.font-size-50= avgResponseTime
                                    label.uk-vertical-align-middle.font-size-20(style="margin-top:20px;") s
                                label.font-size-20 Response Time
                        table.uk-table.uk-table-striped.uk-table-hover.uk-margin-large-top
                            thead
                                tr(style="border-top:1px solid #ddd;")
                                    th Chaincode Name
                                    th Invoke Times
                                    th Response Time
                                    th Invoke History
                            tbody
                                each chaincode in chaincodes
                                    tr
                                        td= chaincode.name
                                        td
                                            label.invokeTimes= chaincode.invoke_times
                                        td
                                            label.responseTime= parseFloat(chaincode.avg_response_time.toFixed(2)) + "s"
                                        td
                                            button.uk-button.uk-button-primary.uk-button-small.uk-margin-right(
                                                type="button" data-type="functions" data-id=chaincode.id) Functions
                                                | &nbsp;
                                                i.uk-icon-pie-chart.uk-margin-small-left
                                            | &nbsp;
                                            button.uk-button.uk-button-primary.uk-button-small(
                                                type="button" data-type="responseTime" data-id=chaincode.id) Response Time
                                                | &nbsp;
                                                i.uk-icon-bar-chart.uk-margin-small-left
                    else
                        label.uk-margin-large-top.empty No result.
        div(style="height:80px;")